/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Model.Hotel;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

/**
 *
 * @author Sony
 */
@ManagedBean(name="hotels")
@RequestScoped
public class HotelController {
    HotelHelper helper;
    private Hotel newHotel;
    DataModel lstHotels;

    public HotelController(){
        helper = new HotelHelper();
        newHotel = new Hotel();
    }
    
    public DataModel listHotels(){
        lstHotels = new ListDataModel(this.helper.getAllHotels());
        return lstHotels;
    }
    
    public void addHotel(){
        this.helper.updateHotel(newHotel);
    }
    
    public void editHotel(Hotel h){
        this.helper.updateHotel(h);
    }
    
    public void deleteHotel(Hotel h){
        this.helper.deleteHotel(h);
    }
    /**
     * @return the newHotel
     */
    public Hotel getNewHotel() {
        return newHotel;
    }

    /**
     * @param newHotel the newHotel to set
     */
    public void setNewHotel(Hotel newHotel) {
        this.newHotel = newHotel;
    }
}
